package com.wwz.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

import java.util.List;

/**
 * <p>Description:处理当前用户的任务</p >
 * <p>Copyright: Copyright (c)2021</p >
 * 操作的表：
 *        act_hi_actinst
 *        act_hi_identitylink
 *        act_hi_taskinst
 *        act_ru_execution
 *        act_ru_identitylink
 *        act_ru_task
 * <P>Created Date :2021-04-06</P>
 * <P>@version 1.0</P>
 */
public class ActivitiCompleteTask {
    public static void main(String[] args) {
        //1.得到ProcessEngine
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

        //2.得到TaskService对象
        TaskService taskService = processEngine.getTaskService();

        //3.查询当前用户任务
        Task task = taskService.createTaskQuery()
                .processDefinitionKey("holiday2")
                .taskAssignee("wangwanzhao")
                .singleResult();
        //4.处理任务，结合当前用户任务列表的查询操作  task.getId()
        taskService.complete(task.getId());

        //5.任务id展示
        System.out.println(task.getId());


    }
}
